define([ "app", "jquery", "md5", "ecb","artDialog","iframeTools", "pagination", "services/UserService","services/TipsService",
		"directives/AudioPlayer",
		"resources/company/CompanyResource",
		"resources/UserResource", "resources/ShareResource" ],
		function(app) {
			var deps = [ "$scope", "$state","$sce", "$timeout", "$window", "$location", "$stateParams","TipsService", "UserService", "UserResource", "ShareResource","CompanyResource" ];

			function controller($scope, $state,$sce,$timeout, $window, $location, $stateParams,TipsService, UserService, UserResource, ShareResource,CompanyResource) {
				
				$scope.positionVo={};
				$scope.positionVo.workNature=1;
				init();
				
				function init (){
					
					CompanyResource.queryPostIno(1,null).success(function(data){
						$scope.postList1=data.obj;
		            });
					
				}
				
				
				$scope.choosePost =function (type){
					if(type==1){
						var parentId =$scope.positionVo.positionType1;
						CompanyResource.queryPostIno(2,parentId).success(function(data){
							$scope.postList2=data.obj;
			            });
					}else{
						var parentId =$scope.positionVo.positionType2;
						CompanyResource.queryPostIno(3,parentId).success(function(data){
							$scope.postList3=data.obj;
			            });
					}
					
				}
				
				// 发布职位
				$scope.releasePosition= function($event){
					$state.go('home.releaseResume');
		        };
		        
		        // 保存职位
				$scope.savePosition= function(){
					
					// 验证信息
					if($scope.positionVo.positionName==null || $scope.positionVo.positionName ==""){
						art.dialog.alert("职位名称不能为空！");
						return;
					}
					
					if($scope.positionVo.positionType1==null || $scope.positionVo.positionType1 ==""){
						art.dialog.alert("请选择职位！");
						return;
					}
					
					if($scope.positionVo.positionType2==null || $scope.positionVo.positionType2 ==""){
						art.dialog.alert("请选择职位！");
						return;
					}
					
					if($scope.positionVo.positionType3==null || $scope.positionVo.positionType3 ==""){
						art.dialog.alert("请选择职位！");
						return;
					}
					
					if($scope.positionVo.workNature==null || $scope.positionVo.workNature ==""){
						art.dialog.alert("请选择工作性质！");
						return;
					}
					if($scope.positionVo.experience==null || $scope.positionVo.experience ==""){
						art.dialog.alert("请选择经验质！");
						return;
					}
					if($scope.positionVo.education==null || $scope.positionVo.education ==""){
						art.dialog.alert("请选择学历！");
						return;
					}
					if($scope.positionVo.salaryBegin==null || $scope.positionVo.salaryBegin ==""){
						art.dialog.alert("请设置薪资开始值！");
						return;
					}
					if($scope.positionVo.salaryEnd==null || $scope.positionVo.salaryEnd ==""){
						art.dialog.alert("请设置薪资结束值！");
						return;
					}
					
					var obj ={};
					obj=$scope.positionVo;
					obj.workNature=$("#workNature").val();
					CompanyResource.savePosition(obj).success(function(data){
						$state.go('home.recruitManagement');
		            });
		        };
		        
		        
		        $scope.cancle= function(){
					$state.go('home.recruitManagement');
		        };
		        
		        // 发布职位
				$scope.changeColor= function(type){
					
					$("#workNature").val(type);
					$scope.positionVo.workNature=type;
					if(type==1){
						$("#id1").addClass("position_leida_select");
						$("#id3").removeClass("position_leida_select");
						$("#id2").removeClass("position_leida_select")
						$("#id2").addClass("position_leida");
						$("#id3").addClass("position_leida");
					}
					
					if(type==2){
						$("#id2").addClass("position_leida_select");
						$("#id1").addClass("position_leida");
						$("#id3").addClass("position_leida");
						$("#id3").removeClass("position_leida_select");
						$("#id1").removeClass("position_leida_select")
					}
					
					if(type==3){
						$("#id3").addClass("position_leida_select");
						$("#id1").addClass("position_leida");
						$("#id2").addClass("position_leida");
						$("#id1").removeClass("position_leida_select");
						$("#id2").removeClass("position_leida_select")
					}
		        };
		        
			}
			controller.$inject = deps;
			return app.lazy.controller("ReleaseResumeController", controller);
		});
